<?php

use plugin\tmadmin\app\controller\AccountController;
use plugin\tmadmin\app\controller\AdminController;
use plugin\tmadmin\app\controller\ConfigController;
use plugin\tmadmin\app\controller\DictController;
use plugin\tmadmin\app\controller\IndexController;
use plugin\tmadmin\app\controller\PluginController;
use plugin\tmadmin\app\controller\RoleController;
use plugin\tmadmin\app\controller\RuleController;
use plugin\tmadmin\app\controller\TableController;
use plugin\tmadmin\app\controller\UploadController;
use plugin\tmadmin\app\controller\UserController;
use Webman\Route;

// 禁用tmadmin插件的默认路由，不影响主项目
Route::disableDefaultRoute('tmadmin');

Route::group('/app/tmadmin', function () {
      Route::get('/plugin/list', [PluginController::class, 'list'])->name('app.tmadmin.plugin.list');
      Route::post('/plugin/install', [PluginController::class, 'install'])->name('app.tmadmin.plugin.install');
      Route::post('/plugin/uninstall', [PluginController::class, 'uninstall'])->name('app.tmadmin.plugin.uninstall');
      Route::post('/plugin/pay', [PluginController::class, 'pay'])->name('app.tmadmin.plugin.pay');
      Route::post('/plugin/captcha', [PluginController::class, 'captcha'])->name('app.tmadmin.plugin.captcha');
      Route::post('/plugin/login', [PluginController::class, 'login'])->name('app.tmadmin.plugin.login');
      
      Route::post('/login', [AccountController::class, 'login'])->name('app.tmadmin.login');
      Route::post('/logout', [AccountController::class, 'logout'])->name('app.tmadmin.logout');
      Route::get('/captcha/{type}', [AccountController::class, 'captcha'])->name('app.tmadmin.captcha');

      Route::get('/account/info', [AccountController::class, 'info'])->name('app.tmadmin.account.info');
      Route::post('/account/update', [AccountController::class, 'update'])->name('app.tmadmin.account.update');
      Route::post('/account/password', [AccountController::class, 'password'])->name('app.tmadmin.account.password');

      Route::get('/admins',[AdminController::class,'select'])->name('app.tmadmin.admins.index');
      Route::post('/admins',[AdminController::class,'insert'])->name('app.tmadmin.admins.store');
      Route::post('/admins/update',[AdminController::class,'update'])->name('app.tmadmin.admins.update');
      Route::post('/admins/delete',[AdminController::class,'delete'])->name('app.tmadmin.admins.delete');

      Route::get('/configs',[ConfigController::class,'get'])->name('app.tmadmin.configs.get');
      Route::post('/configs',[ConfigController::class,'update'])->name('app.tmadmin.configs.update');

      Route::get('/dicts',[DictController::class,'select'])->name('app.tmadmin.dicts.index');
      Route::get('/dicts/get/{name}',[DictController::class,'get'])->name('app.tmadmin.dicts.get');
      Route::post('/dicts',[DictController::class,'insert'])->name('app.tmadmin.dicts.store');
      Route::post('/dicts/update',[DictController::class,'update'])->name('app.tmadmin.dicts.update');
      Route::post('/dicts/delete',[DictController::class,'delete'])->name('app.tmadmin.dicts.delete');

      Route::get('/dashboard',[IndexController::class,'dashboard'])->name('app.tmadmin.dashboard');

      Route::get('/roles', [RoleController::class, 'select'])->name('app.tmadmin.roles.index');
      Route::get('/roles/rules', [RoleController::class, 'rules'])->name('app.tmadmin.roles.rules');
      Route::post('/roles', [RoleController::class, 'insert'])->name('app.tmadmin.roles.store');
      Route::post('/roles/update', [RoleController::class, 'update'])->name('app.tmadmin.roles.update');
      Route::post('/roles/delete', [RoleController::class, 'delete'])->name('app.tmadmin.roles.delete');

      Route::get('/rules', [RuleController::class, 'select'])->name('app.tmadmin.rules.index');
      Route::post('/rules', [RuleController::class, 'insert'])->name('app.tmadmin.rules.store');
      Route::post('/rules/update', [RuleController::class, 'update'])->name('app.tmadmin.rules.update');
      Route::post('/rules/delete', [RuleController::class, 'delete'])->name('app.tmadmin.rules.delete');
      Route::get('/rules/permission', [RuleController::class, 'permission'])->name('app.tmadmin.rules.permission');

      Route::get('/users', [UserController::class, 'index'])->name('app.tmadmin.users.index');
      Route::post('/users', [UserController::class, 'insert'])->name('app.tmadmin.users.store');
      Route::post('/users/update', [UserController::class, 'update'])->name('app.tmadmin.users.update');
      Route::post('/users/delete', [UserController::class, 'delete'])->name('app.tmadmin.users.delete');

      Route::get('/uploads', [UploadController::class, 'select'])->name('app.tmadmin.uploads.index');
      Route::post('/uploads', [UploadController::class, 'insert'])->name('app.tmadmin.uploads.store');
      Route::post('/uploads/update', [UploadController::class, 'update'])->name('app.tmadmin.uploads.update');
      Route::post('/uploads/delete', [UploadController::class, 'delete'])->name('app.tmadmin.uploads.delete');
      Route::post('/uploads/file', [UploadController::class, 'file'])->name('app.tmadmin.uploads.file');
      Route::post('/uploads/image', [UploadController::class, 'image'])->name('app.tmadmin.uploads.image');
      Route::post('/uploads/avatar', [UploadController::class, 'avatar'])->name('app.tmadmin.uploads.avatar');

      Route::get('/tables/show',[TableController::class,'show'])->name('app.tmadmin.tables.show');
      Route::post('/tables/create',[TableController::class,'create'])->name('app.tmadmin.tables.create');
      Route::post('/tables/modify',[TableController::class,'modify'])->name('app.tmadmin.tables.modify');
      Route::post('/tables/drop',[TableController::class,'drop'])->name('app.tmadmin.tables.drop');
      Route::get('/tables/schema',[TableController::class,'schema'])->name('app.tmadmin.tables.schema');
      Route::get('/tables/types',[TableController::class,'types'])->name('app.tmadmin.tables.types');
      Route::add(['GET','POST'],'/tables/crud',[TableController::class,'crud'])->name('app.tmadmin.tables.crud');
      // 数据库记录
      Route::get('/tables/select',[TableController::class,'select'])->name('app.tmadmin.tables.select');
      Route::post('/tables/insert',[TableController::class,'insert'])->name('app.tmadmin.tables.insert');
      Route::post('/tables/update',[TableController::class,'update'])->name('app.tmadmin.tables.update');
      Route::post('/tables/delete',[TableController::class,'delete'])->name('app.tmadmin.tables.delete');
  

});